home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / os2 / nortutil.zip / src / TaxLaw / taxlaw.c < prev    next >
C/C++ Source or Header  |  1996-08-28  |  10KB  |  395 lines

  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4.  
  5. extern long time();
  6. extern char *index();
  7. extern void srand();
  8.  
  9. #define first 1
  10. #define second 2
  11.  
  12. char *_article[]={
  13.         "the ",
  14.         "a ",
  15.         "this ",
  16.         "that ",
  17.         "each "
  18. };
  19.  
  20. char *_connect[]={
  21.         "and ",
  22.         "if it ",
  23.         "or ",
  24.         "unless it ",
  25.         "until it ",
  26.         "before it "
  27. };
  28.  
  29. char *_join[]= {
  30.         "while ",
  31.         "because ",
  32.         "although ",
  33.         "even though ",
  34.         "despite the fact that ",
  35.         "for the simple reason that ",
  36.         "because ",
  37.         "due to the fact that ",
  38.         "since ",
  39.         "whether or not ",
  40.         "inasmuch as ",
  41.         "as "
  42. };
  43.  
  44. char *_pronoun[]={
  45.         "alternate ",
  46.         "first ",
  47.         "large ",
  48.         "limited ",
  49.         "long ",
  50.         "second ",
  51.         "serious ",
  52.         "simple ",
  53.         "subsequent ",
  54.         "third ",
  55.         "unusable ",
  56.         "one-time ",
  57.         "add-back ",
  58.         "city, state or local ",
  59.         "minimum ",
  60.         "maximum ",
  61.         "qualified ",
  62.         "exempt ",
  63.         "appropriate ",
  64.         "real ",
  65.         "authorized ",
  66.         "requested ",
  67.         "nonresident "
  68. };
  69.  
  70. char *_noun[]={
  71.         "deduction ",
  72.         "accumulation distribution credit ",
  73.         "addition ",
  74.         "adjustment ",
  75.         "amended return ",
  76.         "amortization ",
  77.         "amount owed ",
  78.         "basis ",
  79.         "beneficiary ",
  80.         "business income ",
  81.         "deduction ",
  82.         "dependant ",
  83.         "depletion ",
  84.         "depreciation ",
  85.         "education expense ",
  86.         "estate ",
  87.         "trust ",
  88.         "estimated tax ",
  89.         "exemption ",
  90.         "family adjustment ",
  91.         "gift for wildlife ",
  92.         "house-hold credit ",
  93.         "investment credit ",
  94.         "retail enterprise credit ",
  95.         "refund ",
  96.         "lump sum distribution ",
  97.         "maximum tax on personal service income ",
  98.         "minimum income tax ",
  99.         "new business investment ",
  100.         "deferral ",
  101.         "exclusion ",
  102.         "overpayment ",
  103.         "partner ",
  104.         "payment ",
  105.         "penalty and interest ",
  106.         "pension and annuity income ",
  107.         "real property tax credit ",
  108.         "research and development credit ",
  109.         "resident credit ",
  110.         "retail enterprise credit ",
  111.         "seperate tax ",
  112.         "tuition deduction ",
  113.         "group term life insurance policy ",
  114.         "package ",
  115.         "solar and wind energy credit "
  116. };
  117.  
  118. char *_prep[]={
  119.         "across ",
  120.         "by ",
  121.         "in ",
  122.         "near ",
  123.         "under ",
  124.         "over ",
  125.         "in back of ",
  126.         "below ",
  127.         "behind ",
  128.         "connected with ",
  129.         "centered around ",
  130.         "centered about ",
  131.         "in close proximity to ",
  132.         "following after ",
  133.         "in between ",
  134.         "in conflict with ",
  135.         "in conjunction with ",
  136.         "in the area of ",
  137.         "in the neighborhood of ",
  138.         "in the proximity of ",
  139.         "in the field of ",
  140.         "for the purpose of ",
  141.         "giving rise to ",
  142.         "based upon ",
  143.         "being caused by ",
  144.         "being used with ",
  145.         "being collected together with ",
  146.         "being combined together with ",
  147.         "connected up to ",
  148.         "exhibiting a tendency towards ",
  149.         "being facilitated by ",
  150.         "being employed with ",
  151.         "having a deleterious effect upon ",
  152.         "impacting ",
  153.         "being joined together with ",
  154.         "being merged together with ",
  155.         "in the vicinity of ",
  156.         "above ",
  157.         "across from ",
  158.         "along ",
  159.         "among ",
  160.         "beneath ",
  161.         "between ",
  162.         "beyond ",
  163.         "by ",
  164.         "covering ",
  165.         "enclosing ",
  166.         "for ",
  167.         "from ",
  168.         "in ",
  169.         "inside ",
  170.         "inbetween ",
  171.         "joining ",
  172.         "opposite ",
  173.         "outside ",
  174.         "over ",
  175.         "under ",
  176.         "with " };
  177.  
  178. char *_adverb[]= {
  179.         "that ",
  180.         "which "
  181. };
  182.  
  183. char *_verb[]={
  184.         "applies ",
  185.         "collects ",
  186.         "deducts ",
  187.         "distributes ",
  188.         "enters ",
  189.         "exempts ",
  190.         "figures ",
  191.         "files ",
  192.         "has ",
  193.         "keeps ",
  194.         "refunds ",
  195.         "receives ",
  196.         "subtracts ",
  197.         "signs ",
  198.         "states ",
  199.         "with-holds ",
  200.         "multiplies ",
  201.         "adds ",
  202.         "subtracts ",
  203.         "divides ",
  204.         "pays ",
  205.         "enjoins ",
  206.         "makes ",
  207.         "obtains ",
  208.         "recovers ",
  209.         "exempts ",
  210.         "expects ",
  211.         "computes ",
  212.         "changes ",
  213.         "debits ",
  214.         "credits ",
  215.         "produces ",
  216.         "develops ",
  217.         "invents ",
  218.         "claims ",
  219.         "checks ",
  220.         "qualifies ",
  221.         "removed ",
  222.         "ends ",
  223.         "retires ",
  224.         "chooses ",
  225.         "seperates ",
  226.         "trusts ",
  227.         "invests ",
  228.         "looses ",
  229.         "buys ",
  230.         "sells "
  231. };
  232.  
  233. char buffer[3000];
  234. int _rflag = first;
  235. int connectflag = 0;
  236.  
  237.  
  238. taxlaw()
  239. {
  240.         char *pb = buffer;
  241.         _taxlaw();
  242.         *(pb + strlen(buffer)-1) = '\0';
  243.         strcat(buffer, ".\n");
  244.         *pb = _toupper(*pb);
  245.         wrap_puts(buffer);
  246.         _rflag = first;
  247.         connectflag = 0;
  248. }
  249.  
  250. _taxlaw()
  251. {
  252.         static int _time = first;
  253.         char *pick();
  254.         int whichflag = 0;
  255.         char bullbuf[80];
  256.  
  257.         if(strlen(buffer) > 2998)
  258.         {
  259. #ifdef EBUG
  260.                 printf("buffer overflow");
  261. #endif
  262.                 return;
  263.         }
  264.  
  265.         if(_rflag == first)
  266.         {
  267.                 buffer[0] = '\0';
  268.                 _rflag = second;
  269.                 setbuf(stdout, NULL);
  270.         }
  271.  
  272.         if(_time == first)
  273.         {
  274.                 srand( (unsigned)time( (long *)0 ) );
  275.                 _time = second;
  276.         }
  277.  
  278.         for(;;)
  279.         {
  280.                 while(rnd(10) > 4)
  281.                 {
  282.                         strcat(buffer, pick(_article,sizeof(_article),1));
  283.                         while(rnd(3) == 1)
  284.                                 strcat(buffer, pick(_pronoun,sizeof(_pronoun),0));
  285.                         strcat(buffer, pick(_noun,sizeof(_noun),0));
  286.                         strcat(buffer, pick(_prep,sizeof(_prep),0));
  287.                 }
  288.                 strcat(buffer, pick(_article,sizeof(_article),1));
  289.                 while(rnd(3) == 1)
  290.                         strcat(buffer, pick(_pronoun,sizeof(_pronoun),0));
  291.                 strcat(buffer, pick(_noun,sizeof(_noun),0));
  292.                 if(rnd(8)==1)
  293.                 {
  294.                         strcat(buffer, pick(_adverb,sizeof(_adverb),1));
  295.                         whichflag = 1;
  296.                 }
  297.                 strcat(buffer, pick(_verb,sizeof(_verb),0));
  298.                 strcat(buffer, pick(_article,sizeof(_article),1));
  299.                 while(rnd(3) == 1)
  300.                         strcat(buffer, pick(_pronoun,sizeof(_pronoun),0));
  301.                 strcat(buffer, pick(_noun,sizeof(_noun),0));
  302.                 if(rnd(10) > 4)
  303.                 {
  304.                         sprintf(bullbuf,"(See sect. &%d, para. %d) ",rnd(80),rnd(999));
  305.                         strcat(buffer,bullbuf);
  306.                 }
  307.  
  308.                 if(rnd(10) >= 7)
  309.                 {
  310.                         strcat(buffer,pick(_join,sizeof(_join),0));
  311. #ifdef EBUG
  312.                         puts("beginning recursion");
  313. #endif
  314.                         _taxlaw();
  315. #ifdef EBUG
  316.                         puts("ending recursion");
  317. #endif
  318.                         strcat(buffer,pick(_join,sizeof(_join),0));
  319.                         connectflag = 1;
  320.                 }
  321.                 else
  322.                         break;
  323.         }
  324.         if(whichflag)
  325.         {
  326.                 if(connectflag)
  327.                         strcat(buffer, pick(_connect,sizeof(_connect),1));
  328.                 else
  329.                         connectflag = 1;